#![deny(warnings)]

mod context;
mod runtime;
mod value;
mod internal;
mod js_class;

#[macro_use]
extern crate c_str_macro;
pub use qjs_sys as q;
pub use context::{JSContext,EvalType,JSPropertyItemValue,JSPropertyItem,property_list_to_c};
pub use runtime::{JSRuntime};
pub use value::{RawJsValue,AutoDropJSValue,JSValue};
pub use internal::{init_internal};
pub use js_class::{JSClass,JSClassOject};

static INLINE_CODE:&str = "function require(path) { return __require(path,function() {});};console.error = function(obj) { return console.__error(JSON.stringify(obj)); };console.log = function(obj) {return console.__log(JSON.stringify(obj));};console.warn = function(obj) {return console.__warn(JSON.stringify(obj));};";

#[cfg(test)]
mod tests {
    use crate::runtime::{JSRuntime};
    use crate::context::{JSContext,JSPropertyItem};
    use crate::internal::{init_internal};
    use qjs_sys as q;
    #[test]
    fn it_works() {
      let rt  = JSRuntime::new().unwrap();
      let mut ctx = JSContext::new(&rt).unwrap();
      init_internal(&mut ctx,&rt);
      
     
   
     
      //let str:String = String::from("import * as f from 'first'; \r\n var a = require('first'); console.log(a.version); ");
      let _propslist = vec!(
                           JSPropertyItem::int32(c_str!("ccccc"), 667, q::JS_PROP_CONFIGURABLE as u8),
                           JSPropertyItem::string(c_str!("version"), c_str!("1.10.0"), q::JS_PROP_CONFIGURABLE as u8),
                          );
       //ctx.add_c_module("first",&propslist);
       ctx.eval_file("test/main.js");
    }

   
      
    
}
